#include<bits/stdc++.h>
using namespace std;
int t;
struct car{
    int di,vi,ai;
}a[100005];
int p[100005];
int b[100005][3];
int main(){

  freopen("detect.in","r",stdin);
 freopen("detect.out","w",stdout);
    //cout<<1;
    cin>>t;
    while(t--){
        int n,m,l,v;
        cin>>n>>m>>l>>v;
        int ansy=0,ans=n,cnt=0;
        cout<<1;
        for(int i=1;i<=n;i++){
            scanf("%d %d %d",&a[i].di,&a[i].vi,&a[i].ai);
        }
        for(int i=1;i<=m;i++) scanf("%d",&p[i]);
        for(int i=1;i<=n;i++){
            if(a[i].ai==0){
                   // cout<<1;
                if(p[m]<a[i].di || a[i].vi<=v) ans--;
                else ansy=1;
                //cout<<ans;
            }
            else if(a[i].ai>0){
                if(p[m]<a[i].di) ans--;
                else{
                    double s=(p[m]-a[i].di)*1.0;
                    double vs=sqrt( (a[i].vi)*(a[i].vi)+2*a[i].vi*s*1.0);
                    if(vs-0.01<=v*1.0) ans--;
                    else ansy=1;
                }
            }
            else if(a[i].ai<0){
                if(p[n]<a[i].di) ans--;
                else if(a[i].vi<v) ans--;
                else{
                     int t=p[lower_bound(p+1,p+n+1,a[i].di)-p];
                     double s=(t-a[i].di)*1.0;
                     double vs=sqrt( (a[i].vi)*(a[i].vi)+2*a[i].vi*s*1.0);
                     if(vs-0.01<=v*1.0) ans--;
                     else{
                        int tt=p[lower_bound(p+1,p+n+1,a[i].di+floor(((v*v-a[i].vi*a[i].vi)*0.5)/(-a[i].ai)))-p];
                        b[++cnt][1]=t;
                        b[cnt][2]=tt;
                     }
                }
            }
        }

        printf("%d %d\n",ans,m-ansy);
    }
    return 0;
}
